#pragma once
#include <assert.h>
#include <Windows.h>
#include <gdiplus.h>
#pragma comment(lib, "gdiplus.lib")
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "winmm.lib")
#include "__Singleton__.h"

class DL_Initialize
{
	friend struct _Default_Deleter<DL_Initialize>;
	friend class __Singleton__<DL_Initialize>;

	ULONG_PTR					_M_gdiplusToken;
	DL_Initialize()
	{
		CoInitializeEx(0, COINIT_MULTITHREADED);

		WORD sockVersion = MAKEWORD(2, 2);
		WSADATA wsaData;
		if (WSAStartup(sockVersion, &wsaData) != 0)
		{
			assert(0);
		}

		Gdiplus::GdiplusStartupInput gdiplusStartupInput;
		Gdiplus::GdiplusStartup(&_M_gdiplusToken, &gdiplusStartupInput, NULL);
		timeBeginPeriod(1);
	}

	~DL_Initialize()
	{
		Gdiplus::GdiplusShutdown(_M_gdiplusToken);
		CoUninitialize();
		WSACleanup();
		timeEndPeriod(1);
	}
};


#define G_Initialize() __Singleton__<DL_Initialize>::instance()